﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace WpfApp1
{
    /// <summary>
    /// WindowGrid.xaml 的交互逻辑
    /// </summary>
    public partial class WindowGrid : Window
    {
        public WindowGrid()
        {
            InitializeComponent();
        }


        public   ObservableCollection<CurrentDataClass> currentDatalist= new ObservableCollection<CurrentDataClass>();

        public ObservableCollection<WarnEventClass> warnEventlist= new ObservableCollection<WarnEventClass>();
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            //添加测试报警数据
            string[] warntype = new string[] { "血压","呼吸","心率","其他"};

            string[] warnremark = new string[] { "血压过高>120", "血压过低<70", "呼吸过低<10", "心率太低<50", "心率太高>120","其他" };
            string[] warnlevel=new string[] { "低级", "中级", "高级"  };

            for (int i =1;i<30;i++)
            {
                WarnEventClass warnEvent = new WarnEventClass();
                warnEvent.ID = i;
                warnEvent.timeindex = i * 100;
                warnEvent.warntime = DateTime.Now.ToLocalTime().ToString() ;
                warnEvent.warntype = warntype[i % 4];
                warnEvent.warnlevel = warnlevel[i%3];
                warnEvent.warndata = "30";
                warnEvent.remark = warnremark[i % 6];
                warnEventlist.Add(warnEvent);
            }

            WarnDataGrid.ItemsSource = warnEventlist;

            //添加测试 实时测量数据
            for (int i = 1; i < 50; i++)
            {
                CurrentDataClass currentdata = new CurrentDataClass();

                BedDataClass beddata = new BedDataClass();
                beddata.id = i;
                beddata.bedangle = i * 2;
                beddata.bedstatus = i <15 ? "平躺位" : "倾斜";
                BPDataClass bpdata = new BPDataClass();
                bpdata.ID = i;
                bpdata.sbpValue = 120;
                bpdata.dbpValue = 80;

                BreateDataClass breateData = new BreateDataClass();
                breateData.breateValue = i;
                currentdata.beddata = beddata;
                currentdata.bpdata = bpdata;
                currentdata.breateData = breateData;
                currentdata.ID = i;
                currentdata.Hr = 60 + i;
                currentdata.STJ = 1.0/i;
                currentdata.time = DateTime.Now.ToLongTimeString();

                currentDatalist.Add(currentdata);
            }
            CurrentDataListGrid.ItemsSource = currentDatalist;

        }
    }
}
